import Vue from 'vue'
import App from './App'

import store from './store'

Vue.prototype.$store = store
Vue.config.productionTip = false
// 引入全局组件
import divider from './components/common/divider.vue';
Vue.component('divider', divider)
import cuCustom from './colorui/components/cu-custom.vue'
Vue.component('cu-custom', cuCustom)
// 引入配置文件
import $C from './common/config.js';
Vue.prototype.$C = $C
// 挂在助手函数库
import $U from './common/util.js';
Vue.prototype.$U = $U
// 引入请求库
import $H from './common/request.js';
Vue.prototype.$H = $H
// 权限验证操作
Vue.prototype.checkAuth = (callback) => {
	// 权限验证

	if (!store.state.hasLogin) {
		uni.showToast({
			title: '请先登录',
			icon: 'none'
		});
		return uni.navigateTo({
			url: '/pages/login/login'
		});
	}
	callback()
}

// 权限验证跳转
Vue.prototype.navigateTo = (options) => {
	// 权限验证
	if (!store.state.hasLogin) {
		uni.showToast({
			title: '请先登录',
			icon: 'none'
		});
		return uni.navigateTo({
			url: '/pages/login/login'
		});
	}
	uni.navigateTo(options);
}
App.mpType = 'app'
const platform = uni.getSystemInfoSync().platform;
const jyJPush = uni.requireNativePlugin('JY-JPush');
/*
jyJPush.addJYJPushReceiveNotificationListener(result => {
	console.log(result)
	//  监听成功后，若收到推送，会在result返回对应的数据；数据格式保持极光返回的安卓/iOS数据一致
	let extrasJson = result;
	if (platform == "android") {
		let notificationExtras = result['notificationExtras'];
		if (notificationExtras !== null) {
			extrasJson = JSON.parse(notificationExtras);
		} else {
			return;
		}
	}
	console.log(extrasJson)
	if (extrasJson['retype']) {
		if (extrasJson['retype'] == 'request') {
			if (extrasJson['restate'] == 1) {
				uni.navigateTo({
					url: '/pages/prepare-receiver-lawyer/prepare-receiver-lawyer?modalData=' + encodeURIComponent(JSON.stringify(
						extrasJson))
				});
			} else {
				uni.$emit('receiverPush', {
					restate: false
				})
			}
		} else if (extrasJson['retype'] == 'receiver') {
			console.log('retype')
			if (extrasJson['restate'] == 1) {
				uni.$emit('requestPush', {
					restate: true
				})
			} else {
				uni.$emit('requestPush', {
					restate: false
				})
			}

		}
	}

});
jyJPush.addJYJPushReceiveOpenNotificationListener(result => {
	//  监听成功后，若点击推送消息，会触发result；数据格式保持极光返回的安卓/iOS数据一致
	console.log(JSON.stringify(result));
	uni.showToast({
		icon: 'none',
		title: JSON.stringify(result)
	});
});
jyJPush.getRegistrationID(
	//  返回的数据会有registrationID，errorCode
	result => {
		console.log(JSON.stringify(result));
	});
*/	
const app = new Vue({
	store,
	...App
})
app.$mount()
